package routers

import (
	"dc-news/common/middleware/jwt"
	"dc-news/controller"
	"github.com/gin-gonic/gin"
)

func SetupUserRouter(r *gin.Engine) {
	v1Group := r.Group("api/v1")

	noAuthGroup := v1Group.Group("")
	{
		noAuthGroup.POST("login", controller.LoginHandler)
		noAuthGroup.POST("register", controller.RegisterHandler)
		noAuthGroup.POST("password/reset", controller.ResetPasswordEmailHandler)
		noAuthGroup.PUT("password/reset", controller.ResetPasswordHandler)
		noAuthGroup.POST("email/confirm", controller.ConfirmEmailHandler)
	}

	authGroup := v1Group.Group("user")
	authGroup.Use(jwt.Auth(true))
	{
		authGroup.GET("info", controller.GetUserInfoHandler)
		authGroup.GET("setting", controller.GetUserSettingHandler)
		authGroup.PUT("setting", controller.UpdateUserSettingHandler)
		authGroup.PUT("info", controller.UpdateUserInfoHandler)
		authGroup.POST("avatar/upload", controller.UploadAvatarHandler)
		authGroup.GET("channels", controller.GetUserChannelsHandler)
		authGroup.GET("news/favorites", controller.GetUserFavouriteNewsHandler)
		authGroup.GET("news/likes", controller.GetUserLikesNewsHandler)
		authGroup.GET("comments", controller.GetUserCommentsHandler)
		authGroup.GET("comment/likes", controller.GetUserLikesCommentsHandler)
		authGroup.GET("report", controller.GetUserReportService)
	}

}
